// components/date-time-selector/date-time-selector.js
const {formatTime} = require('../../utils/util')

Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    date: formatTime(new Date()),
    time: '00:00'
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onchange(e){
      let {
        detail: {value},
        currentTarget: {dataset: {mode}}
      } = e
      let data = {}
      let mergeValue = ''

      data[mode] = value
      mergeValue = Object.values(Object.assign({}, this.data, data)).join(' ')

      this.setData(data)
      this.triggerEvent('change', { value: mergeValue })
    },
  }
})
